//app.js
import Config from "./main.config";
import {wxLogin} from "./service/Common";
import {setStorage} from "./utils/Storage";
import PageExtend from "./utils/PageExtend";
import ComponentExtend from "./utils/ComponentExtend.js";
App({
    onLaunch: function () {
        Page = PageExtend(Page); //Page页面对象扩展
        // Component = ComponentExtend(Component); //Component组件对象扩展
        this.getOpenId();
    },

    /*
    * 小程序登录
    * */
    getOpenId: async function () {
        try {
            let openId = await wxLogin();
            setStorage(Config.storage.openId, openId);
            this.globalData.openId = openId;
            this.getOpenIdCallback && typeof this.getOpenIdCallback === "function" ? this.getOpenIdCallback(openId): null;
        } catch (e) {

        }
    },

    onShow: function () {

    },

    globalData: {
        openId: null,
        isLoginExpired: false, //登录过期
        userInfo: null  //用户数据
    }
})